document.addEventListener('plusready',function(){
	var uid = plus.storage.getItem('uid');
	var ws = plus.webview.currentWebview();
	var id = ws.aid;
	var spage = ws.spage;	//收藏列表
	var cur = plus.webview.getWebviewById(spage);
	console.log(id);
	console.log(apiRoot+"/home/article/oneNew/uid/"+uid+"/aid/"+id);
	//判断是否收藏了该资讯
	$.ajax({
		type:"get",
		url:apiRoot+"/home/article/oneNew",
		data:{
			uid :uid,
			aid :id
		}, 
		dataType :'json',
		success :function(data){
//			console.log(JSON.stringify(data));
			if(data.iscollect > 0){	//收藏了
				$('.iconfont').addClass('red');
			}
			$('.title').text(data.title);
			$('.name').text(data.issuedname);
			$('.time').text(data.addtime);  
			$('.contbody').html(data.body.replace(/src="/g ,'src="'+webRoot));
		},
		error :function(e){
			console.log(JSON.stringify(e));
		}
	});
	if(!uid){
		return;
	}
	//点击收藏
	$('.iconfont').on('tap', function(){
		var _this = $(this);
		$.ajax({
			type:"get",
			url:apiRoot+"/home/article/collectNew",
			data:{
				uid :uid,
				aid :id
			}, 
			success :function(data){
				console.log(data); 
				if(data > 0){
					if(_this.hasClass('red')){
						_this.removeClass('red');
						toast('取消收藏');
						if(spage)cur.evalJS('List()');
					}else{
						_this.addClass('red');
						toast('收藏成功');
						if(spage)cur.evalJS('List()');
					}
				}else{
					toast('操作失败'); 
				}
			},
			error :function(e){
				console.log(JSON.stringify(e));
			}
		});
	})
},false)